{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "67816ac1",
   "metadata": {},
   "source": [
    "# week09"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4953a314",
   "metadata": {},
   "source": [
    "## 1.上周的数据结构跟随老师的步骤成功版练习：购物车程序项目"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "216fe270",
   "metadata": {},
   "source": [
    "![字典](https://img-blog.csdnimg.cn/20200801173837286.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ1ODcwNTc2,size_16,color_FFFFFF,t_70)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "11b31816",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 商品的数据信息\n",
    "goods_list = [\n",
    "    # [商品名称，商品价格]\n",
    "    ['珍珠奶茶',7],\n",
    "    ['大杯珍珠奶茶',8.5],\n",
    "    ['加大杯珍珠奶茶',9.5],\n",
    "    ['桶装珍珠奶茶',20]\n",
    "]\n",
    "user_shopping_car = []\n",
    "# 用户输入 使用input，结果是一个字符串\n",
    "Alipay = int(input(\"请输入你的余额：\"))\n",
    "\n",
    "while True:\n",
    "    # 循环遍历商品列表，将商品信息按照一定格式输出\n",
    "    # 一定格式：商品编号：xx，商品名称：xx，商品价格：xx\n",
    "    print(\"------ 请选择编号 欢迎选购 ------\")\n",
    "    for i in range(len(goods_list)):# range会根据商品列表的长度变化而变化\n",
    "        print(\"商品编号：%s,商品名称：%s,商品价格：%s\"%(i,goods_list[i][0],goods_list[i][1]))\n",
    "\n",
    "    # 2.让用户输入商品编号进行商品的购买\n",
    "    # 1.用户输入的内容是否符合规范（用户买的东西有没有）？\n",
    "\n",
    "    choice = input(\"请正确输入购买商品的编号：\")\n",
    "    if choice.isdigit():# isdigit 判断字符串里面的内容是否是数值\n",
    "        choice = int(choice)\n",
    "        if choice > len(goods_list):\n",
    "            #   b.如果没有该商品，返回没有\n",
    "            print(\"您选择的商品不存在\")\n",
    "        else:\n",
    "            #   a.如果有 判断金额是否够:用户金额 Alipay 商品的金额 goods_list[choice][1]\n",
    "            if Alipay > goods_list[choice][1]:\n",
    "                # 用户余额够 1.增加该商品到用户购物车 2.扣除余额\n",
    "                user_shopping_car.append(goods_list[choice])\n",
    "                Alipay = Alipay - goods_list[choice][1]\n",
    "                print(\"%s已经加入您的购物车，您的【账户余额】还有：%s元\"%(goods_list[choice][0],Alipay))\n",
    "            else:\n",
    "                print(\"您的余额不足，请更改支付方式\")\n",
    "    elif choice == \"q\":\n",
    "        # 用户退出购买\n",
    "        print(\"用户购物车：\",user_shopping_car)\n",
    "        print(\"您的余额还有：\",Alipay)\n",
    "        break\n",
    "    else:\n",
    "        print(\"请输入商品编号！！！\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d6a0a182",
   "metadata": {},
   "source": [
    "## 2.字典"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "607dd015",
   "metadata": {},
   "source": [
    "## 元组(tuple)\n",
    "\n",
    "* [元组]  \n",
    "> 1.它是和list几乎完全一样的序列数据  \n",
    "> 2.它与list不同的地方是，**不可变8**(因为不可变，所以几乎没有方法)  \n",
    "> 3.元组的形式：(1,2,3,4,5)对比 元组() 列表[]  "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "916574cd",
   "metadata": {},
   "source": [
    "### 时间"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "4faf31ee",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "12205d45",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2021, tm_mon=11, tm_mday=3, tm_hour=22, tm_min=47, tm_sec=5, tm_wday=2, tm_yday=307, tm_isdst=0)"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.localtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "4f7316a8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in module time:\n",
      "\n",
      "NAME\n",
      "    time - This module provides various functions to manipulate time values.\n",
      "\n",
      "DESCRIPTION\n",
      "    There are two standard representations of time.  One is the number\n",
      "    of seconds since the Epoch, in UTC (a.k.a. GMT).  It may be an integer\n",
      "    or a floating point number (to represent fractions of seconds).\n",
      "    The Epoch is system-defined; on Unix, it is generally January 1st, 1970.\n",
      "    The actual value can be retrieved by calling gmtime(0).\n",
      "    \n",
      "    The other representation is a tuple of 9 integers giving local time.\n",
      "    The tuple items are:\n",
      "      year (including century, e.g. 1998)\n",
      "      month (1-12)\n",
      "      day (1-31)\n",
      "      hours (0-23)\n",
      "      minutes (0-59)\n",
      "      seconds (0-59)\n",
      "      weekday (0-6, Monday is 0)\n",
      "      Julian day (day in the year, 1-366)\n",
      "      DST (Daylight Savings Time) flag (-1, 0 or 1)\n",
      "    If the DST flag is 0, the time is given in the regular time zone;\n",
      "    if it is 1, the time is given in the DST time zone;\n",
      "    if it is -1, mktime() should guess based on the date and time.\n",
      "\n",
      "CLASSES\n",
      "    builtins.tuple(builtins.object)\n",
      "        struct_time\n",
      "    \n",
      "    class struct_time(builtins.tuple)\n",
      "     |  struct_time(iterable=(), /)\n",
      "     |  \n",
      "     |  The time value as returned by gmtime(), localtime(), and strptime(), and\n",
      "     |  accepted by asctime(), mktime() and strftime().  May be considered as a\n",
      "     |  sequence of 9 integers.\n",
      "     |  \n",
      "     |  Note that several fields' values are not the same as those defined by\n",
      "     |  the C language standard for struct tm.  For example, the value of the\n",
      "     |  field tm_year is the actual year, not year - 1900.  See individual\n",
      "     |  fields' descriptions for details.\n",
      "     |  \n",
      "     |  Method resolution order:\n",
      "     |      struct_time\n",
      "     |      builtins.tuple\n",
      "     |      builtins.object\n",
      "     |  \n",
      "     |  Methods defined here:\n",
      "     |  \n",
      "     |  __reduce__(...)\n",
      "     |      Helper for pickle.\n",
      "     |  \n",
      "     |  __repr__(self, /)\n",
      "     |      Return repr(self).\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Static methods defined here:\n",
      "     |  \n",
      "     |  __new__(*args, **kwargs) from builtins.type\n",
      "     |      Create and return a new object.  See help(type) for accurate signature.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data descriptors defined here:\n",
      "     |  \n",
      "     |  tm_gmtoff\n",
      "     |      offset from UTC in seconds\n",
      "     |  \n",
      "     |  tm_hour\n",
      "     |      hours, range [0, 23]\n",
      "     |  \n",
      "     |  tm_isdst\n",
      "     |      1 if summer time is in effect, 0 if not, and -1 if unknown\n",
      "     |  \n",
      "     |  tm_mday\n",
      "     |      day of month, range [1, 31]\n",
      "     |  \n",
      "     |  tm_min\n",
      "     |      minutes, range [0, 59]\n",
      "     |  \n",
      "     |  tm_mon\n",
      "     |      month of year, range [1, 12]\n",
      "     |  \n",
      "     |  tm_sec\n",
      "     |      seconds, range [0, 61])\n",
      "     |  \n",
      "     |  tm_wday\n",
      "     |      day of week, range [0, 6], Monday is 0\n",
      "     |  \n",
      "     |  tm_yday\n",
      "     |      day of year, range [1, 366]\n",
      "     |  \n",
      "     |  tm_year\n",
      "     |      year, for example, 1993\n",
      "     |  \n",
      "     |  tm_zone\n",
      "     |      abbreviation of timezone name\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data and other attributes defined here:\n",
      "     |  \n",
      "     |  n_fields = 11\n",
      "     |  \n",
      "     |  n_sequence_fields = 9\n",
      "     |  \n",
      "     |  n_unnamed_fields = 0\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Methods inherited from builtins.tuple:\n",
      "     |  \n",
      "     |  __add__(self, value, /)\n",
      "     |      Return self+value.\n",
      "     |  \n",
      "     |  __contains__(self, key, /)\n",
      "     |      Return key in self.\n",
      "     |  \n",
      "     |  __eq__(self, value, /)\n",
      "     |      Return self==value.\n",
      "     |  \n",
      "     |  __ge__(self, value, /)\n",
      "     |      Return self>=value.\n",
      "     |  \n",
      "     |  __getattribute__(self, name, /)\n",
      "     |      Return getattr(self, name).\n",
      "     |  \n",
      "     |  __getitem__(self, key, /)\n",
      "     |      Return self[key].\n",
      "     |  \n",
      "     |  __getnewargs__(self, /)\n",
      "     |  \n",
      "     |  __gt__(self, value, /)\n",
      "     |      Return self>value.\n",
      "     |  \n",
      "     |  __hash__(self, /)\n",
      "     |      Return hash(self).\n",
      "     |  \n",
      "     |  __iter__(self, /)\n",
      "     |      Implement iter(self).\n",
      "     |  \n",
      "     |  __le__(self, value, /)\n",
      "     |      Return self<=value.\n",
      "     |  \n",
      "     |  __len__(self, /)\n",
      "     |      Return len(self).\n",
      "     |  \n",
      "     |  __lt__(self, value, /)\n",
      "     |      Return self<value.\n",
      "     |  \n",
      "     |  __mul__(self, value, /)\n",
      "     |      Return self*value.\n",
      "     |  \n",
      "     |  __ne__(self, value, /)\n",
      "     |      Return self!=value.\n",
      "     |  \n",
      "     |  __rmul__(self, value, /)\n",
      "     |      Return value*self.\n",
      "     |  \n",
      "     |  count(self, value, /)\n",
      "     |      Return number of occurrences of value.\n",
      "     |  \n",
      "     |  index(self, value, start=0, stop=9223372036854775807, /)\n",
      "     |      Return first index of value.\n",
      "     |      \n",
      "     |      Raises ValueError if the value is not present.\n",
      "\n",
      "FUNCTIONS\n",
      "    asctime(...)\n",
      "        asctime([tuple]) -> string\n",
      "        \n",
      "        Convert a time tuple to a string, e.g. 'Sat Jun 06 16:26:11 1998'.\n",
      "        When the time tuple is not present, current time as returned by localtime()\n",
      "        is used.\n",
      "    \n",
      "    ctime(...)\n",
      "        ctime(seconds) -> string\n",
      "        \n",
      "        Convert a time in seconds since the Epoch to a string in local time.\n",
      "        This is equivalent to asctime(localtime(seconds)). When the time tuple is\n",
      "        not present, current time as returned by localtime() is used.\n",
      "    \n",
      "    get_clock_info(...)\n",
      "        get_clock_info(name: str) -> dict\n",
      "        \n",
      "        Get information of the specified clock.\n",
      "    \n",
      "    gmtime(...)\n",
      "        gmtime([seconds]) -> (tm_year, tm_mon, tm_mday, tm_hour, tm_min,\n",
      "                               tm_sec, tm_wday, tm_yday, tm_isdst)\n",
      "        \n",
      "        Convert seconds since the Epoch to a time tuple expressing UTC (a.k.a.\n",
      "        GMT).  When 'seconds' is not passed in, convert the current time instead.\n",
      "        \n",
      "        If the platform supports the tm_gmtoff and tm_zone, they are available as\n",
      "        attributes only.\n",
      "    \n",
      "    localtime(...)\n",
      "        localtime([seconds]) -> (tm_year,tm_mon,tm_mday,tm_hour,tm_min,\n",
      "                                  tm_sec,tm_wday,tm_yday,tm_isdst)\n",
      "        \n",
      "        Convert seconds since the Epoch to a time tuple expressing local time.\n",
      "        When 'seconds' is not passed in, convert the current time instead.\n",
      "    \n",
      "    mktime(...)\n",
      "        mktime(tuple) -> floating point number\n",
      "        \n",
      "        Convert a time tuple in local time to seconds since the Epoch.\n",
      "        Note that mktime(gmtime(0)) will not generally return zero for most\n",
      "        time zones; instead the returned value will either be equal to that\n",
      "        of the timezone or altzone attributes on the time module.\n",
      "    \n",
      "    monotonic(...)\n",
      "        monotonic() -> float\n",
      "        \n",
      "        Monotonic clock, cannot go backward.\n",
      "    \n",
      "    monotonic_ns(...)\n",
      "        monotonic_ns() -> int\n",
      "        \n",
      "        Monotonic clock, cannot go backward, as nanoseconds.\n",
      "    \n",
      "    perf_counter(...)\n",
      "        perf_counter() -> float\n",
      "        \n",
      "        Performance counter for benchmarking.\n",
      "    \n",
      "    perf_counter_ns(...)\n",
      "        perf_counter_ns() -> int\n",
      "        \n",
      "        Performance counter for benchmarking as nanoseconds.\n",
      "    \n",
      "    process_time(...)\n",
      "        process_time() -> float\n",
      "        \n",
      "        Process time for profiling: sum of the kernel and user-space CPU time.\n",
      "    \n",
      "    process_time_ns(...)\n",
      "        process_time() -> int\n",
      "        \n",
      "        Process time for profiling as nanoseconds:\n",
      "        sum of the kernel and user-space CPU time.\n",
      "    \n",
      "    sleep(...)\n",
      "        sleep(seconds)\n",
      "        \n",
      "        Delay execution for a given number of seconds.  The argument may be\n",
      "        a floating point number for subsecond precision.\n",
      "    \n",
      "    strftime(...)\n",
      "        strftime(format[, tuple]) -> string\n",
      "        \n",
      "        Convert a time tuple to a string according to a format specification.\n",
      "        See the library reference manual for formatting codes. When the time tuple\n",
      "        is not present, current time as returned by localtime() is used.\n",
      "        \n",
      "        Commonly used format codes:\n",
      "        \n",
      "        %Y  Year with century as a decimal number.\n",
      "        %m  Month as a decimal number [01,12].\n",
      "        %d  Day of the month as a decimal number [01,31].\n",
      "        %H  Hour (24-hour clock) as a decimal number [00,23].\n",
      "        %M  Minute as a decimal number [00,59].\n",
      "        %S  Second as a decimal number [00,61].\n",
      "        %z  Time zone offset from UTC.\n",
      "        %a  Locale's abbreviated weekday name.\n",
      "        %A  Locale's full weekday name.\n",
      "        %b  Locale's abbreviated month name.\n",
      "        %B  Locale's full month name.\n",
      "        %c  Locale's appropriate date and time representation.\n",
      "        %I  Hour (12-hour clock) as a decimal number [01,12].\n",
      "        %p  Locale's equivalent of either AM or PM.\n",
      "        \n",
      "        Other codes may be available on your platform.  See documentation for\n",
      "        the C library strftime function.\n",
      "    \n",
      "    strptime(...)\n",
      "        strptime(string, format) -> struct_time\n",
      "        \n",
      "        Parse a string to a time tuple according to a format specification.\n",
      "        See the library reference manual for formatting codes (same as\n",
      "        strftime()).\n",
      "        \n",
      "        Commonly used format codes:\n",
      "        \n",
      "        %Y  Year with century as a decimal number.\n",
      "        %m  Month as a decimal number [01,12].\n",
      "        %d  Day of the month as a decimal number [01,31].\n",
      "        %H  Hour (24-hour clock) as a decimal number [00,23].\n",
      "        %M  Minute as a decimal number [00,59].\n",
      "        %S  Second as a decimal number [00,61].\n",
      "        %z  Time zone offset from UTC.\n",
      "        %a  Locale's abbreviated weekday name.\n",
      "        %A  Locale's full weekday name.\n",
      "        %b  Locale's abbreviated month name.\n",
      "        %B  Locale's full month name.\n",
      "        %c  Locale's appropriate date and time representation.\n",
      "        %I  Hour (12-hour clock) as a decimal number [01,12].\n",
      "        %p  Locale's equivalent of either AM or PM.\n",
      "        \n",
      "        Other codes may be available on your platform.  See documentation for\n",
      "        the C library strftime function.\n",
      "    \n",
      "    thread_time(...)\n",
      "        thread_time() -> float\n",
      "        \n",
      "        Thread time for profiling: sum of the kernel and user-space CPU time.\n",
      "    \n",
      "    thread_time_ns(...)\n",
      "        thread_time() -> int\n",
      "        \n",
      "        Thread time for profiling as nanoseconds:\n",
      "        sum of the kernel and user-space CPU time.\n",
      "    \n",
      "    time(...)\n",
      "        time() -> floating point number\n",
      "        \n",
      "        Return the current time in seconds since the Epoch.\n",
      "        Fractions of a second may be present if the system clock provides them.\n",
      "    \n",
      "    time_ns(...)\n",
      "        time_ns() -> int\n",
      "        \n",
      "        Return the current time in nanoseconds since the Epoch.\n",
      "\n",
      "DATA\n",
      "    altzone = -32400\n",
      "    daylight = 0\n",
      "    timezone = -28800\n",
      "    tzname = ('中国标准时间', '中国夏令时')\n",
      "\n",
      "FILE\n",
      "    (built-in)\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(time)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "98be0384",
   "metadata": {},
   "source": [
    "### 名字"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "29ac9ccc",
   "metadata": {},
   "outputs": [],
   "source": [
    "names = \"zengqiaoyi\",\"yaoxiaole\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "9712241e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('zengqiaoyi', 'yaoxiaole')"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "47f096ee",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tuple"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(names)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fa012fa5",
   "metadata": {},
   "source": [
    "### 查询出现次数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "4f2cb02f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.count(\"zengqiaoyi\")#查询出现次数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "7f93fe23",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.index(\"yaoxiaole\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f14641a1",
   "metadata": {},
   "source": [
    "# 字典(dict)\n",
    "> 1.字典的创建方式  \n",
    ">> 1.直接创建字典，按照字典的结构：{key1:value1,key2:value2,......}  \n",
    ">> 2.dict()创建字典，dict(key1=value1,key2=value2,...)  \n",
    ">> 3.新建空字典  \n",
    "> 2.字典的性质  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "b042214d",
   "metadata": {},
   "outputs": [],
   "source": [
    "stu_info = {\n",
    "    \"stu10001\":\"Alex\",\n",
    "    \"stu10002\":\"Jack\",\n",
    "    \"stu10003\":\"Marry\"\n",
    "}\n",
    "\n",
    "stu10001 = {\n",
    "    \"name\":\"Alex\",\n",
    "    \"age\":18,\n",
    "    \"job\":\"student\"\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "30562806",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stu10001': 'Alex', 'stu10002': 'Jack', 'stu10003': 'Marry'}"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stu_info"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "085b5ad7",
   "metadata": {},
   "source": [
    "## 第二种创建字典的方法\n",
    "## 与第一种的区别\n",
    "###    1.dict()VS{}\n",
    "###    2.stu10001 VS \"stu10001\"\n",
    "###    3.= VS :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "d1118afb",
   "metadata": {},
   "outputs": [],
   "source": [
    "stu_info_02 = dict(\n",
    "    stu10001 = \"Alex\",\n",
    "    stu10002 = \"Jack\",\n",
    "    stu10003 = \"Marry\",\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "66300d31",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stu10001': 'Alex', 'stu10002': 'Jack', 'stu10003': 'Marry'}"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stu_info_02"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "267356ee",
   "metadata": {},
   "source": [
    "## 第三种创建字典的方式，新建空字典，然后增加值得到方式创建字典\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "0a5472cc",
   "metadata": {},
   "outputs": [],
   "source": [
    "stu_info_03 = {}\n",
    "\n",
    "stu_info_03['stu10001'] = \"Alex\" # 字典的增加\n",
    "stu_info_03['stu10002'] = \"Jack\"\n",
    "stu_info_03['stu10003'] = \"Marry\"\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "6daac77d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stu10001': 'Alex', 'stu10002': 'Jack', 'stu10003': 'Marry'}"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stu_info_03"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "76294ad5",
   "metadata": {},
   "source": [
    "# week09作业：\n",
    "> 1.请尝试使用和学习字典的方法  \n",
    "> 2.给一组数据，利用字典查询的方式尝试查找指定的数据（）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "559c00f3",
   "metadata": {},
   "outputs": [],
   "source": [
    "constellation = ['白羊座：有一种让人看起来就觉得开心的感觉，阳光、乐观、坚强，性格直来直往，就是有点小脾气',\n",
    "          '金牛座：很保守，喜欢稳定，一旦有什么变动就会觉得心里不踏实，性格比较慢热，是个理财高手',\n",
    "          '双子座：喜欢追求新鲜感，有点小聪明，耐心不够，因为可爱的性格会让很多人喜欢和你做朋友',\n",
    "          '巨蟹座：情绪容易敏感，缺乏安全感，做事情有坚持到底的毅力，为人重情义，对朋友和家人特别忠实',\n",
    "          '狮子座：有着宏伟的理想，总想靠自己的努力成为人上人，向往高高在上的优越感，也期待被崇拜的感觉',\n",
    "          '处女座：坚持追求自己的完美主义者',\n",
    "          '天秤座：追求平等、和谐，擅于察言观色，交际能力很强，因此真心朋友不少，最大的缺点是面对选择总是犹豫不决',\n",
    "          '天蝎座：精力旺盛，占有欲强，对于生活很有目标，不达目的誓不罢休，复仇心强',\n",
    "          '射手座：崇尚自由，勇敢、果断、独立，身上有一股勇往直前的劲儿，只要想做就能做',\n",
    "          '摩羯座：最有耐心，处事小心谨慎，心地善良，做事脚踏实地，也比较固执，不达目的不放手，而且非常勤奋',\n",
    "          '水瓶座：人很聪明，喜欢创新，追求独一无二的生活，个人主义色彩很浓重',\n",
    "          '双鱼座：心地善良，乐于助人，及所有星座优缺点于一身']\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "0aa79422",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "list"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(constellation)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "58301a1a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "phrase = \"白羊座\"\n",
    "freq_table_phrase =  constellation.count(phrase)\n",
    "freq_table_phrase"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b8709c99",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
